package iterators;

import IA.MenuItem;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Pop
 */
public class MenuByRatingItr implements Iterator{
    List<MenuItem> menu;
    Double rating;
    
    public MenuByRatingItr(List<MenuItem> menu, Double rating){
        this.menu = menu;
        this.rating = rating;
    }
    @Override
    public boolean hasNext() {
        boolean isValid = false;
        while(!isValid && !menu.isEmpty()){
            if(menu.get(0).getRating() > rating){
                isValid = true;
            } else{
            menu.remove(0); 
            }
        }
        return isValid;
    }

    @Override
    public MenuItem next() {
        MenuItem item = menu.get(0);
        menu.remove(0);
        return item;
    }

    @Override
    public void remove() {
        menu.remove(0);
    }
    
}
